/**
 * @summary 文章请求模块
 */
import req from '@/utils/request';
import * as URL from '@/constants/api';

export function getSearchList(q) {
  return req({
    url: URL.SEARCH_LIST,
    params: {
      q,
    },
  })
    // 处理成功
    .then(res => res.data.data.options.filter(o => o ?.trim()))
    // 处理失败
    .catch(() => [])
}
// 搜索结果模块
export function getSearchResult(searchValue) {
  return req({
    url: URL.SEARCH,
    params: {
      q: searchValue,
    },
  })
    // 处理成功
    .then(res => res.data.data.results)
    // 处理失败
    .catch(() => null)
}
